<template>
  <q-page class="down-page q-pa-md">
    <div class="flex items-center q-mt-sm">
      <div
        class="center q-mr-sm"
        style="border-radius: 14px; border: 1px solid #fff; overflow: hidden"
      >
        <img src="~/assets/images/public/logo.png" style="width: 48px" />
      </div>
      <div>
        <div class="flex items-center">
          <div class="center">
            <img src="~/assets/images/public/logo_text.png" style="height: 15px" />
          </div>
          <div
            class="q-mx-xs"
            style="background-color: #9f896d; width: 1.5px; height: 14px; opacity: 0.24"
          ></div>
          <div style="color: #4c3c30; font-size: 13px">正规持牌消费金融机构</div>
        </div>

        <div class="flex q-mt-xs">
          <div
            style="
              background: #FF3E7E;
              border-radius: 0px 6px 6px 6px;
              padding: 3px 6px;
              color: #fff;
              font-size: 12px;
            "
          >
            年华利率7.2%-24% (单利）
          </div>
        </div>
      </div>
    </div>

    <div class="" style="margin-top: 40px">
      <div
        class="bg-white q-mx-auto relative-position center"
        style="width: 80px; height: 80px; border-radius: 999999px; z-index: 2"
      >
        <img src="~/assets/images/down/icon.png" style="width: 54px" />
      </div>
      <div
        class="bg-white relative-position text-center"
        style="
          min-height: 300px;
          border-radius: 12px;
          margin-top: -40px;
          z-index: 1;
          padding-top: 40px;
          padding-bottom: 8px;
        "
      >
        <div class="text-weight-bold" style="font-size: 16px">预审成功!</div>

        <div class="q-mt-md">
          <span>恭喜您获得资方审批</span
          ><span
            class="q-px-xs"
            style="color: #FF3E7E; font-size: 32px; font-family: DIN-Medium, DIN"
            >186,000</span
          ><span>额度</span>
        </div>

        <div class="flex items-center justify-center q-mt-lg">
          <q-icon name="south" size="xs" style="color: #096AFF" />
          <div style="color: #666666">令日激活额度享极速下款特权</div>
          <q-icon name="south" size="xs" style="color: #096AFF" />
        </div>

        <div class="center q-mt-lg">
          <img src="~/assets/images/down/img1.png" class="q-mx-auto" style="height: 60px" />
        </div>

        <q-btn
          unelevated
          rounded
          padding="none none"
          @click="downHandler"
          class="down-btn q-mx-auto q-mx-auto q-mt-lg"
          style=""
        >
          下载App 提现额度

          <div class="pointer">
            <img src="~/assets/images/public/pointer.png" style="display: block; width: 45px" />
          </div>
        </q-btn>

        <div class="center q-mt-md">
          <img src="~/assets/images/down/tipbottom.png" class="q-mx-auto" style="width: calc(100% - 20px)" />
        </div>

      </div>
    </div>
    <div class="" style="height: 50px"></div>
    <a :href="androidDownLink" ref="downARef" download style="display: none;"></a>
  </q-page>
</template>

<script setup lang="ts">
import { isIOS } from 'mobile-device-detect';
import { judgeBrand } from 'src/utils/lib';
import { computed, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';

const router = useRouter()
const route = useRoute()

const downARef = ref<HTMLLinkElement>()
const downHandler = () => {
  if (isIOS) {
    return router.replace({ path: '/prodList', query: route.query });
  } else {
    downARef.value?.click()
  }
}


const phoneType = judgeBrand(navigator.userAgent)

const androidDownLink = computed(() => {
  if (phoneType === 'huawei') {
    return 'apks/huawei_1.0.3.apk'
  }
  if (phoneType === 'vivo') {
    return 'apks/vivo_1.0.4.apk'
  }
  if (phoneType === 'xiaomi') {
    return 'apks/xiaomi_1.0.4.apk'
  }
  return 'apks/oppo_1.0.3.apk'
})


console.log(phoneType)

</script>

<style lang="scss" scoped>
.down-page {
  background-color: #F4F6F9;
  background-image: url(src/assets/images/down/bg.png);
  background-repeat: no-repeat;
  background-size: 100% auto;
}
.down-btn {
  background: #096AFF;
  color: #fff;
  cursor: pointer;
  border-radius: 99999px;
  width: 80%;
  font-weight: bold;
  font-size: 15px;
  min-height: 40px;
  padding: 12px !important;
  position: relative;
  .pointer {
    position: absolute;
    right: calc(15% - 22px);
    top: 42%;
  }
}
</style>
